package CanvaWeb.CanvaWeb.Service;

import CanvaWeb.CanvaWeb.Repository.DrawingRepository;
import CanvaWeb.CanvaWeb.pojo.Drawing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DrawingService {

    @Autowired
    private DrawingRepository drawingRepository;

    // 保存绘画数据
    public void saveDrawing(String playerName, String drawingData, Long roomId, String hint,String word) {
        Drawing drawing = new Drawing(playerName, drawingData, roomId, hint,word);
        drawingRepository.save(drawing);
    }

    // 获取某个房间的所有绘画数据
    public List<Drawing> getDrawingsByRoom(Long roomId) {
        return drawingRepository.findByRoomId(roomId);
    }
}

